import { NestFactory } from "@nestjs/core";
import { DicomServerModule } from "./dicom-server.module";
import { configuration } from "../../../config/config";
import { MicroserviceOptions, Transport } from "@nestjs/microservices";

async function bootstrap() {
  const app = await NestFactory.create(DicomServerModule);

  await Promise.all([
    // app.listen(configuration.dicomServer.http_port),  // 启动 HTTP 服务
    app.connectMicroservice<MicroserviceOptions>({
      transport: Transport.NATS,
      options: {
        servers: configuration.natsServer,
      },
    }),
  ]);

  // 启动所有微服务
  await app.startAllMicroservices();

  console.log(
    "dicomServer is running on http port " +
      configuration.dicomServer.http_port,
    "nats client start",
  );
}
bootstrap();
